"""
响应数据模型
"""
from typing import List, Optional
from pydantic import BaseModel, Field


class UploadResponse(BaseModel):
    """文本上传响应"""
    status: str = Field(..., description="处理状态")
    filename: str = Field(..., description="文件名")
    chunk_count: int = Field(..., description="文本块数量")
    total_characters: int = Field(..., description="总字符数")
    processing_time: float = Field(..., description="处理耗时（秒）")


class ContextBlock(BaseModel):
    """上下文文本块"""
    text: str = Field(..., description="文本内容")
    similarity: float = Field(..., description="相似度分数")
    document: str = Field(..., description="来源文档")


class DocumentInfo(BaseModel):
    """文档信息"""
    filename: str = Field(..., description="文件名")
    upload_time: float = Field(..., description="上传时间戳")
    file_size: int = Field(..., description="文件大小（字节）")
    chunk_count: int = Field(..., description="文本块数量")
    total_characters: int = Field(..., description="总字符数")


class KnowledgeStatusResponse(BaseModel):
    """知识库状态响应"""
    total_documents: int = Field(..., description="文档总数")
    total_chunks: int = Field(..., description="文本块总数")
    total_characters: int = Field(..., description="总字符数")
    last_updated: Optional[float] = Field(None, description="最后更新时间戳")
    embedding_model: str = Field(..., description="使用的 embedding 模型")
    is_initialized: bool = Field(..., description="是否已初始化")


class DocumentListResponse(BaseModel):
    """文档列表响应"""
    documents: List[DocumentInfo] = Field(..., description="文档列表")
    total: int = Field(..., description="文档总数")


class DeleteDocumentResponse(BaseModel):
    """删除文档响应"""
    status: str = Field(..., description="操作状态")
    filename: str = Field(..., description="被删除的文件名")
    deleted_chunks: int = Field(..., description="删除的文本块数量")


class HealthResponse(BaseModel):
    """健康检查响应"""
    status: str = Field(..., description="服务状态")
    version: str = Field(..., description="版本信息")

